package com.wc.fortnight_blue_bridge.Q241005.B_净化王胖子;

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.util.Arrays;
import java.util.StringTokenizer;

/**
 * @Author congge
 * @Date 2024/10/5 19:09
 * @description
 */
public class Main {
    /**
     * 思路；
     * 需要按照编号1 -> 2 -> ... -> n
     * 经过的相邻的, 可以用差分, 然后看经过哪里一个相邻的最大, 那就先用, 可以以最大程度少建
     */
    static FastReader sc = new FastReader();
    static PrintWriter out = new PrintWriter(System.out);
    static int N = 200010;
    static int[] a = new int[N], map = new int[N], sum = new int[N];
    static int n, k;

    public static void main(String[] args) {
        n = sc.nextInt();
        k = sc.nextInt();
        for (int i = 1; i <= n; i++) {
            int x = sc.nextInt();
            map[x] = i;
        }
        for (int i = 2; i <= n; i++) {
            int r = map[i], l = map[i - 1];
            if (l > r) {
                l = l + r;
                r = l - r;
                l = l - r;
            }
            sum[l] += 1;
            sum[r] -= 1;
        }
        for (int i = 1; i <= n; i++) sum[i] += sum[i - 1];
        Arrays.sort(sum, 1, n);
        for (int i = 1, j = n - 1; i < j; i++, j--) {
            int tmp = sum[i];
            sum[i] = sum[j];
            sum[j] = tmp;
        }
        int res = -1;
        for (int i = 1; i < n; i++) {
            k -= sum[i];
            if (k <= 0) {
                res = i;
                break;
            }
        }
        out.println(res);
        out.flush();
    }
}

class FastReader {
    StringTokenizer st;
    BufferedReader br;

    FastReader() {
        br = new BufferedReader(new InputStreamReader(System.in));
    }

    String next() {
        while (st == null || !st.hasMoreElements()) {
            try {
                st = new StringTokenizer(br.readLine());
            } catch (IOException e) {
                e.printStackTrace();
            }
        }
        return st.nextToken();
    }

    int nextInt() {
        return Integer.parseInt(next());
    }

    String nextLine() {
        String s = "";
        try {
            s = br.readLine();
        } catch (IOException e) {
            e.printStackTrace();
        }
        return s;
    }

    long nextLong() {
        return Long.parseLong(next());
    }

    double nextDouble() {
        return Double.parseDouble(next());
    }

    // 是否由下一个
    boolean hasNext() {
        while (st == null || !st.hasMoreTokens()) {
            try {
                String line = br.readLine();
                if (line == null)
                    return false;
                st = new StringTokenizer(line);
            } catch (IOException e) {
                throw new RuntimeException(e);
            }
        }
        return true;
    }
}
